﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Manager : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AdminUserID"] == null)
        {
            Response.Write( "<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
           // Response.Write("<script language=javascript>alert('Time is out.');window.open(" + ResolveUrl("~/") + "'Manager/Default.aspx','_top');</script>");
            return;
        }
        /*    if (!IsPostBack)
            {
                CheckPage();
            }*/

    }
    /* protected override void OnInit(EventArgs e)
     {
         if (Session["AdminUserID"] == null)
         {
             Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
             return;
         }
     }*/
    private void CheckPage()
    {
        try
        {
            //if (System.IO.Path.GetFileName(Request.ServerVariables["HTTP_REFERER"]).ToLower() != "default.aspx")
            //{

            if (Request.QueryString["CodeID"] != "0" && Session["IsAdmin"].ToString() != "S" && Session["AutID"].ToString() != "0")
            {
                clsGetMenuAuth clsAuth = new clsGetMenuAuth(Session["AdminUserID"].ToString(), Session["AutID"].ToString(), Session["IsAdmin"].ToString(), Request.QueryString["CodeID"]);
                if (clsAuth.IsShowAuth() == false)
                    Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            }
            else if (Request.QueryString["CodeID"] != "-1" && Session["IsAdmin"].ToString() != "S" && Session["AutID"].ToString() == "0" && Request.QueryString["CodeID"] == "" || Request.QueryString["CodeID"] == null)
            {
                //Response.Redirect("~/Manager/default.aspx");
                Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            }


            //}
        }
        catch
        {
            //Response.Redirect("~/Manager/default.aspx");
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
        }
    }
}
